package com.zhangxx.web.controller;

import com.zhangxx.web.common.model.PageResult;
import com.zhangxx.web.service.BlogAricleService;
import io.swagger.annotations.*;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author zhangbo
 * @date 2019-08-15
 */
@Api(value = "文章相关Api"
)
@RestController
@RequestMapping("/article")
public class BlogArticleController {
    @Resource
    private BlogAricleService blogAricleService;

    @ApiOperation(value="文章列表", notes="查询文章列表")
    @ApiResponses(
            @ApiResponse(code = 200,message = "Success",response = PageResult.class)
    )
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name="id",value = "文章id",paramType = "query"),
            @ApiImplicitParam(name="pageNum",value = "页数",paramType = "query",dataType = "int"),
            @ApiImplicitParam(name="pageSize",value = "每页数量",paramType = "query",dataType = "int"),
            @ApiImplicitParam(name="getContent",value = "是否查询详情",paramType = "query",dataType = "Boolean"),

    }
    )
    @GetMapping
    @ResponseBody
    public  PageResult list(   String id,
                               Integer pageNum,
                             Integer pageSize,
                              Boolean getContent){
        return blogAricleService.list(id, pageNum, pageSize, getContent);
    }
    @ApiOperation(value="文章详情", notes="查询文章详情")
    @ApiResponses(
            @ApiResponse(code = 200,message = "Success",response = PageResult.class)
    )
    @ApiImplicitParams(value = {
            @ApiImplicitParam(name="id",value = "文章id",paramType = "path")

     }
    )
    @GetMapping("/{id}")
    @ResponseBody
    public  PageResult one( @PathVariable String id){
        return blogAricleService.list(id, 1, 1, true);
    }

}
